import express from 'express';
import cookieParser from 'cookie-parser';
import cookieSession from 'cookie-session';
import bodyParser from 'body-parser';
import uuid from 'uuid';
import consoidate from 'consolidate';
import multer from 'multer';
import logger from 'morgan';

const server=express();
server.listen(8080);
server.use(express.static("./public"));
server.use(logger("dev"));
server.use(logger("combined",{stream:require("fs").createWriteStream("./logs/logs.log",{flag:"a"})}));
server.use(cookieParser("ming.cn"));
server.use(cookieSession({
    genid:function(){
        return uuid.v1();
    },
    name:"ming.cn",
    maxAge:1000*60*20,
    secret:"ming.cn"
}));
server.use(bodyParser.urlencoded({
    extended:true,
    limit:"500mb"
}));
server.set("view engine","html");
server.set("views","./views");
server.engine("html",consoidate.ejs);
server.use(multer({"dest":"public/upload"}).any());
server.use("/admin",require("./route/admin/adminRouter"));